package org.jumiz.lowcode.core;

import org.jumiz.lowcode.core.config.JpaConfig;
import org.jumiz.lowcode.core.sys.config.entity.LowcodeConfigTable;
import org.jumiz.lowcode.core.sys.config.entity.LowcodeConfigTableColumn;
import org.jumiz.lowcode.core.sys.config.entity.enums.DataType;
import org.jumiz.lowcode.core.sys.config.entity.enums.Status;
import org.jumiz.lowcode.core.sys.config.service.LowcodeConfigTableService;
import org.jumiz.lowcode.databases.DatabasesStart;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

public class LowcodeCoreApplication {

    public static void main(String[] args) {
        DatabasesStart.main(args);
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(JpaConfig.class);
        LowcodeConfigTableService service = context.getBean(LowcodeConfigTableService.class);
        LowcodeConfigTable table = new LowcodeConfigTable();
        table.setTableName("customer_abc");
        table.setComment("自定义");
        table.setStatus(Status.USING);
        table.setId(1L);

        LowcodeConfigTableColumn column = new LowcodeConfigTableColumn();
        column.setColumnName("");
        column.setComment("");
        column.setId(1L);
        column.setStatus(Status.USING);
        column.setLength(500);
        column.setDataType(DataType.VARCHAR);
        column.setTableName(table.getTableName());
        service.save(table, Arrays.asList(column), null);
    }

}
